export function datePicker(date,format){
  if (date.__proto__.constructor.name !== "Date"){
    return null
  }
  const year = date.getFullYear();
  const month = date.getMonth() + 1;
  const day = date.getDate();
  const hour = date.getHours();
  const minute = date.getMinutes();
  const second = date.getSeconds();
  return format.replace(/yyyy/,year)
               .replace(/MM/,numberFormat(month))
               .replace(/dd/,numberFormat(day))
               .replace(/hh|HH/,numberFormat(hour))
               .replace(/mm/,numberFormat(minute))
               .replace(/ss/,numberFormat(second))
}

export function numberFormat(num){
  // 在数字前面补零
  return num < 10 ? '0' + num : num
}
